const { contextBridge, ipcRenderer } = require('electron')

contextBridge.exposeInMainWorld('electronAPI', {
  platform: process.platform,
  // 渲染进程给主进程发送消息
  sendMessage: (callback) => ipcRenderer.send('message', callback),
  // 渲染进程接受主线程消息
  receiveMessage: (callback) => ipcRenderer.on('message', callback),
  // 渲染进程主动给主线程发送事件得到数据
  invokeMainProcess: async (message) => {
    return await ipcRenderer.invoke('invoke-main-process', message)
  },
  // 检查版本更新
  checkUpdate: (callback) => ipcRenderer.send('checkUpdate', callback),
  // 获取mac地址
  getMacInfo: async () => {
    return await ipcRenderer.invoke('get-mac')
  }
})
